﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:rbn="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Controls.Ribbon"
                    xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Blue.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="EmbeddedRibbonTabControlStyle" TargetType="{x:Type Fluent:RibbonTabControl}">
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="FocusManager.IsFocusScope" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Fluent:RibbonTabControl}">
                    <Grid x:Name="ContentGrid" Height="Auto" VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="24"/>
                            <RowDefinition x:Name="rowDefinition" Height="86"/>
                            <RowDefinition x:Name="rowDefinition1" Height="5"/>
                        </Grid.RowDefinitions>
                        <Border x:Name="border" HorizontalAlignment="Stretch" Margin="0,-1,0,0" Width="Auto" BorderThickness="0,1" Grid.Row="1" BorderBrush="{Binding Path=SelectedItem.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" Background="{DynamicResource RibbonBackgoundBrush}"/>
                        <Border HorizontalAlignment="Stretch" Margin="1,0,1,1" Grid.Row="1" Grid.RowSpan="1">
                            <ContentControl x:Name="mainContentControl" Focusable="False" Margin="0,1,0,0">
                                <ScrollViewer x:Name="contentPresenter" HorizontalAlignment="Stretch" Margin="0" Style="{DynamicResource RibbonScrollViewer}" Content="{TemplateBinding SelectedContent}" Focusable="False"/>
                            </ContentControl>
                        </Border>
                        <Border x:Name="shadowBorder" Margin="0,-1,0,0" VerticalAlignment="Stretch" Width="Auto" Grid.Row="2" Grid.RowSpan="1" BorderThickness="0,1,0,0" BorderBrush="{Binding Path=SelectedItem.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" Background="{Binding Path=SelectedItem.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}">
                            <Border.OpacityMask>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="Black" Offset="0.003"/>
                                    <GradientStop Color="#00000000" Offset="0.991"/>
                                    <GradientStop Color="#7F0A0A0A" Offset="0.16"/>
                                    <GradientStop Color="#FF040404" Offset="0.15"/>
                                </LinearGradientBrush>
                            </Border.OpacityMask>

                        </Border>
                        <Border x:Name="shadowBorder_Copy" Margin="0,-1,0,0" VerticalAlignment="Stretch" Width="Auto" Grid.Row="2" Grid.RowSpan="1" BorderThickness="0,1,0,0" Background="Black" BorderBrush="Black" Opacity="0.3">

                            <Border.OpacityMask>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="Black" Offset="0.003"/>
                                    <GradientStop Color="#00000000" Offset="0.991"/>
                                    <GradientStop Color="#7F0A0A0A" Offset="0.16"/>
                                    <GradientStop Color="#FF040404" Offset="0.15"/>
                                </LinearGradientBrush>
                            </Border.OpacityMask>

                        </Border>
                        <Grid x:Name="TabsGrid" HorizontalAlignment="Stretch" Margin="0" Width="Auto" Grid.RowSpan="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>

                            <Fluent:RibbonScrollViewer x:Name="scrollViewer" HorizontalAlignment="Left" Margin="2,-7,0,0" Width="Auto" Style="{DynamicResource RibbonTabScrollViewer}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" IsHitTestVisible="True">
                                <Fluent:RibbonTabsContainer x:Name="PART_TabsContainer" IsItemsHost="True" Height="Auto" HorizontalAlignment="Stretch" FocusManager.IsFocusScope="False" Margin="0"/>
                            </Fluent:RibbonScrollViewer>
                            <StackPanel x:Name="toolbarPlaceholder" HorizontalAlignment="Left" Grid.Column="1" Orientation="Horizontal" Margin="0,0,0,1">
                                <Grid Width="22" Height="22">
                                    <Image x:Name="image" Source="/Fluent;Component/Themes/Office2010/Images/RibbonPin.png" Stretch="None" Visibility="Collapsed"/>
                                    <Fluent:ToggleButton x:Name="PART_MinimizeButton" Margin="0" Width="22" Height="22" Size="Small" Style="{DynamicResource RibbonTabControlToggleButtonStyle}" Icon="/Fluent;Component/Themes/Office2010/Images/RibbonExpand.png" LargeIcon="/Fluent;Component/Themes/Office2010/Images/RibbonCollapse.png" IsChecked="{Binding Path=IsMinimized, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </Grid>
                                <StackPanel x:Name="PART_ToolbarPanel" Orientation="Horizontal" FocusManager.IsFocusScope="False"/>
                            </StackPanel>
                        </Grid>
                        <Fluent:RibbonPopup x:Name="PART_Popup" PlacementTarget="{Binding Path=SelectedTabItem,RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" StaysOpen="True" AllowsTransparency="True" PopupAnimation="Fade" VerticalOffset="-1" IsOpen="{TemplateBinding IsOpen}" HorizontalOffset="0" Placement="Custom">
                            <Grid Width="Auto" Height="Auto" Margin="0,20">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="86"/>
                                    <RowDefinition Height="5"/>
                                </Grid.RowDefinitions>
                                <Border Height="Auto" BorderBrush="{Binding Path=SelectedItem.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" Background="{DynamicResource RibbonBackgoundBrush}" BorderThickness="0,1">
                                    <ContentControl x:Name="contentControl" Margin="0"/>
                                </Border>
                                <Border Margin="0,-1,0,0" VerticalAlignment="Bottom" Width="Auto" Grid.Row="1" Grid.RowSpan="1" BorderThickness="0,1,0,0" Height="6" BorderBrush="{Binding Path=SelectedItem.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" Background="{Binding Path=SelectedItem.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Border.OpacityMask>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="Black" Offset="0.003"/>
                                            <GradientStop Color="#00000000" Offset="0.991"/>
                                            <GradientStop Color="#7F0A0A0A" Offset="0.16"/>
                                            <GradientStop Color="#FF040404" Offset="0.15"/>
                                        </LinearGradientBrush>
                                    </Border.OpacityMask>

                                </Border>
                                <Border Margin="0" VerticalAlignment="Bottom" Width="Auto" Grid.Row="1" Grid.RowSpan="1" BorderThickness="0,1,0,0" Height="6" BorderBrush="Black" Background="Black" Opacity="0.3">
                                    <Border.OpacityMask>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="Black" Offset="0.003"/>
                                            <GradientStop Color="#00000000" Offset="0.991"/>
                                            <GradientStop Color="#7F0A0A0A" Offset="0.16"/>
                                            <GradientStop Color="#FF040404" Offset="0.15"/>
                                        </LinearGradientBrush>
                                    </Border.OpacityMask>

                                </Border>
                            </Grid>
                        </Fluent:RibbonPopup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMinimized" Value="True">
                            <Setter Property="Height" TargetName="rowDefinition" Value="0"/>
                            <Setter Property="Height" TargetName="rowDefinition1" Value="0"/>
                            <Setter Property="Content" TargetName="mainContentControl" Value="{x:Null}"/>
                            <Setter Property="Content" TargetName="contentControl" Value="{Binding ElementName=contentPresenter, Mode=OneWay}"/>
                            <Setter Property="Visibility" TargetName="border" Value="Collapsed"/>
                            <Setter Property="Visibility" TargetName="shadowBorder" Value="Collapsed"/>
                            <Setter Property="Visibility" TargetName="image" Value="Collapsed"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsOpen" Value="True"/>
                                <Condition Property="IsMinimized" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Visibility" TargetName="image" Value="Visible"/>
                            <Setter Property="Opacity" TargetName="PART_MinimizeButton" Value="0"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}"/>
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}"/>
        <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}"/>
        <Setter Property="Focusable" Value="False"/>
    </Style>

    <Style x:Key="EmbeddedRibbonTitleBarStyle" TargetType="{x:Type Fluent:RibbonTitleBar}">
        <Setter Property="Template" Value="{DynamicResource EmbeddedRibbonTitleBarControlTemplate}"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="FocusManager.IsFocusScope" Value="False"/>
    </Style>
    <ControlTemplate x:Key="EmbeddedRibbonTitleBarControlTemplate" TargetType="{x:Type Fluent:RibbonTitleBar}">
        <Grid Height="25">
            <ContentPresenter x:Name="PART_QuickAccessToolbarHolder" ContentSource="QuickAccessToolBar"/>
            <ContentPresenter x:Name="PART_HeaderHolder" ContentSource="Header" IsHitTestVisible="False" />
            <Fluent:RibbonContextualGroupsContainer x:Name="PART_ItemsContainer" IsItemsHost="True"/>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="EmbRibbonControlTemplate" TargetType="{x:Type rbn:EmbeddedRibbon}">
        <ControlTemplate.Resources>
        </ControlTemplate.Resources>
        <!--<Grid x:Name="PART_LayoutRoot" Width="Auto" Height="Auto">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.252*"/>
            </Grid.RowDefinitions>
           
            <Fluent:RibbonTabControl Style="{DynamicResource EmbeddedRibbonTabControlStyle}" x:Name="PART_RibbonTabControl" Margin="0,2,0,0" Focusable="False"/>
            
        </Grid>-->
        <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.748*"/>
            <RowDefinition Height="0.252*"/>
        </Grid.RowDefinitions>
            <Fluent:RibbonTitleBar x:Name="PART_RibbonTitleBar" Height="0" Style="{DynamicResource EmbeddedRibbonTitleBarStyle}" Margin="20,0,113,0" VerticalAlignment="Top"/>
            <Fluent:RibbonTabControl Style="{DynamicResource EmbeddedRibbonTabControlStyle}" x:Name="PART_RibbonTabControl" Margin="0,0,0,0" Focusable="False"/>
        </Grid>
        <ControlTemplate.Triggers>

            <Trigger Property="IsCollapsed" Value="True">
                <Setter Property="Visibility" TargetName="PART_RibbonTabControl" Value="Collapsed"/>

            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type rbn:EmbeddedRibbon}">
        <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}"/>
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}"/>
        <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}"/>
        <Setter Property="Template" Value="{StaticResource EmbRibbonControlTemplate}"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}"/>
        <Setter Property="FocusManager.IsFocusScope" Value="True"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}"/>
    </Style>
</ResourceDictionary>